package com.wobangkj.common.service.impl;

import com.wobangkj.common.model.crud.Deliver;
import com.wobangkj.common.repository.DeliverRepository;
import com.wobangkj.common.service.DeliverService;
import com.wobangkj.tool.api.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
@Slf4j
public class DeliverServiceImpl implements DeliverService {
    @Autowired
    private DeliverRepository repository;

    @Override
    @SuppressWarnings("Duplicates")
    public Object create(Deliver liked) {
        try {
            Deliver createData = repository.save(liked);
            // 使用 uuid 作为源 token
            //String     token = UUID.randomUUID().toString().replace("-", "");
            //TokenModel model = new TokenModel(createData.getId(), token);
            // 30 分钟有效期
            //cacheManager.set(model.getToken(), new CacheModel(TOKEN_MINUTE, model));
            return Result.GetMapData(Result.CodeCreate, Result.MsgCreate);//, model);
        } catch (Exception e) {
            return Result.GetMapData(Result.CodeSql, e.getCause().getCause().getMessage());
        }
    }

    @Override
    public List<Map> findToMe(String Id) {
        return repository.findToMe(Id);
    }

    @Override
    public List<Map> findMy(String Id) {
        return repository.findMy(Id);
    }

    @Override
    public List<Deliver> findById(String delivererId, String deliverContentId) {
        return repository.findById(delivererId,deliverContentId);
    }

    @Override
    public String getJobId(String ContentId) {
        return repository.getJobId(ContentId);
    }
}
